package br.com.fogas.webservice.repository.soap;

import android.content.Context;
import br.com.fogas.utils.exception.ParseXmlException;
import br.com.fogas.webservice.exception.ERaiseWebServiceException;
import br.com.fogas.webservice.exception.RespostaWebServiceException;
import br.com.fogas.webservice.exception.SemConexaoInternetException;
import br.com.fogas.webservice.exception.ServidorForaException;
import br.com.fogas.webservice.exception.TempoEsperaRespostaException;
import br.com.fogas.webservice.exception.WebServiceException;
import br.com.fogas.webservice.parser.notafiscal.situacao.NotaFiscalSitEnvelope;
import br.com.fogas.webservice.parser.notafiscal.situacao.NotaFiscalSitRequest;
import br.com.fogas.webservice.parser.notafiscal.situacao.NotaFiscalSitResponse;
import br.com.fogas.webservice.repository.IRepositoryHandler;
import br.com.fogas.webservice.soap.impl.NotaFiscalSitSOAP;

public class NotaFiscalSitRepository implements IRepositoryHandler<NotaFiscalSitResponse> {
	
	private Context context;
	private NotaFiscalSitRequest request;

	public NotaFiscalSitRepository(Context context, NotaFiscalSitRequest request) {
		this.context = context;
		this.request = request;
	}

	@Override
	public NotaFiscalSitResponse getResponse() throws SemConexaoInternetException,
			ParseXmlException, TempoEsperaRespostaException,
			ServidorForaException, RespostaWebServiceException,
			WebServiceException, ERaiseWebServiceException {
		
		NotaFiscalSitEnvelope envelope = new NotaFiscalSitEnvelope();
		envelope.body.request = request;
		
		NotaFiscalSitSOAP soap = new NotaFiscalSitSOAP(context, envelope);
		return soap.getResponse();
	}
}
